package com.jingli.pile.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jingli.pile.entity.SupConnectorStatusInfo;
import com.jingli.pile.entity.SupStationStatsInfo;
import com.jingli.pile.entity.SupStationStatusInfo;
import com.jingli.pile.request.StationStatusQueryRequest;
import com.jingli.pile.service.SupConnectorStatusInfoService;
import com.jingli.pile.service.SupStationStatusInfoService;
import com.jingli.pile.mapper.SupStationStatusInfoMapper;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author abdul
* @description 针对表【sup_station_status_info】的数据库操作Service实现
* @createDate 2023-11-16 13:40:18
*/
@Service
public class SupStationStatusInfoServiceImpl extends ServiceImpl<SupStationStatusInfoMapper, SupStationStatusInfo>
    implements SupStationStatusInfoService{
    @Autowired
    private SupConnectorStatusInfoService connectorStatusInfoService;
    @Override
    public List<SupStationStatusInfo> queryStationStatus(StationStatusQueryRequest statusQueryRequest) {
        QueryWrapper<SupStationStatusInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("operator_id",statusQueryRequest.getOperatorID());
        queryWrapper.in("station_id", statusQueryRequest.getStationIDs());
        List<SupStationStatusInfo> list = list(queryWrapper);
        for (SupStationStatusInfo statusInfo: list) {
            QueryWrapper<SupConnectorStatusInfo> connectorStatusInfoQueryWrapper = new QueryWrapper<>();
            connectorStatusInfoQueryWrapper.eq("operator_id",statusQueryRequest.getOperatorID());
            connectorStatusInfoQueryWrapper.eq("station_id",statusInfo.getStationId());
            List<SupConnectorStatusInfo> connectorStatusInfoList = connectorStatusInfoService.list(connectorStatusInfoQueryWrapper);
            statusInfo.setConnectorStatusInfos(connectorStatusInfoList);
        }
        return list;
    }
}




